icon browser: Load app menu automagically
authorMatthias Clasen <mclasen@redhat.com>
Mon, 25 Jan 2016 01:01:33 +0000 (20:01 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 25 Jan 2016 01:01:33 +0000 (20:01 -0500)
No need to manually create a builder and pass the resource to it,
just follow the conventions and have GtkApplication do it for us.

demos/icon-browser/app-menu.ui [deleted file]
demos/icon-browser/iconbrowser.gresource.xml
demos/icon-browser/iconbrowserapp.c
demos/icon-browser/iconbrowserwin.c
demos/icon-browser/menus.ui [new file with mode: 0644]

diff --git a/demos/icon-browser/app-menu.ui b/demos/icon-browser/app-menu.ui
deleted file mode 100644 (file)
index ed89a43..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0"?>
-<interface>
-  <!-- interface-requires gtk+ 3.0 -->
-  <menu id="appmenu">
-    <section>
-      <item>
-        <attribute name="label" translatable="yes">_Quit</attribute>
-        <attribute name="action">app.quit</attribute>
-      </item>
-    </section>
-  </menu>
-</interface>
index 455c684004ac6f5cef4f5b236a0de1a362e90fa3..fd2523a01633deff0052439bc4397727c321f77e 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
-  <gresource prefix="/org/gtk/iconbrowser">
+  <gresource prefix="/org/gtk/iconbrowser/gtk">
     <file preprocess="xml-stripblanks">window.ui</file>
-    <file preprocess="xml-stripblanks">app-menu.ui</file>
+    <file preprocess="xml-stripblanks">menus.ui</file>
   </gresource>
 </gresources>
index 1c9065e6c3774bad0390f0bb363961dc29647fd8..fc291d06f2df1428f953018b112d8e2fbca87091 100644 (file)
@@ -36,8 +36,6 @@ static GActionEntry app_entries[] =
 static void
 icon_browser_app_startup (GApplication *app)
 {
-  GtkBuilder *builder;
-  GMenuModel *app_menu;
   const gchar *quit_accels[2] = { "<Ctrl>Q", NULL };
 
   G_APPLICATION_CLASS (icon_browser_app_parent_class)->startup (app);
@@ -48,11 +46,6 @@ icon_browser_app_startup (GApplication *app)
   gtk_application_set_accels_for_action (GTK_APPLICATION (app),
                                          "app.quit",
                                          quit_accels);
-
-  builder = gtk_builder_new_from_resource ("/org/gtk/iconbrowser/app-menu.ui");
-  app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu"));
-  gtk_application_set_app_menu (GTK_APPLICATION (app), app_menu);
-  g_object_unref (builder);
 }
 
 static void
index ec3a80432bf7d620d2a276c34b0ae3433c9de836..7645dcacecc614c10c4467b4a7ab47fc25f09b12 100644 (file)
@@ -840,7 +840,7 @@ icon_browser_window_class_init (IconBrowserWindowClass *class)
   g_type_ensure (ICON_STORE_TYPE);
 
   gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
-                                               "/org/gtk/iconbrowser/window.ui");
+                                               "/org/gtk/iconbrowser/gtk/window.ui");
 
   gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, context_list);
   gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), IconBrowserWindow, filter_model);
diff --git a/demos/icon-browser/menus.ui b/demos/icon-browser/menus.ui
new file mode 100644 (file)
index 0000000..1a0f0c5
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <menu id="app-menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Quit</attribute>
+        <attribute name="action">app.quit</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>